using System.Collections;
using Holoville.HOTween;
using UnityEngine;

public class WalkWindow : BaseWindow
{
	public static WalkWindow instance;

	public GameObject butDetonator;

	public GameObject rightInterfaceWalk;

	public GameObject centerInterfaceWalk;

	public GameObject panelJoystick;

	public SlotSelector slotSelector;

	public SlotSelector carSelector;

	[HideInInspector]
	public UIButton exampleButWeapon;

	public UIWidget textDamage;

	public UITexture textShock;

	public UILabel lbAmmo;

	public UIJoystick joystickWalk;

	public ManualAimerZone aimerZoneWalk;

	public AimHUD aimHUD;

	public OpticalAimHUD opticalAimHUD;

	public UIButton jumpButton;

	public UIButton jetpackButton;

	public WeaponStrengthIndicator weaponStrange;

	public ButtonShoot butShoot;

	public JetpackFuelBehavior fuelJetpack;

	public bool forceUpdate;

	private void Awake()
	{
		instance = this;
		HOTween.Init();
	}

	private void Start()
	{
	}

	private void OnDestroy()
	{
		instance = null;
	}

	private void OnEnable()
	{
		if (settings.learningCompleted)
		{
			StartCoroutine(UpdateWeapon());
		}
	}

	private void OnDisable()
	{
	}

	public void ChangeColor()
	{
		CoroutineRunner.Instance.StartCoroutine(IChangeColor());
	}

	private IEnumerator IChangeColor()
	{
		if (GameController.instance.curTypeGame != TypeGame.Zombe)
		{
			yield break;
		}
		if (TDMController.myTeam == PunTeams.Team.none)
		{
			yield return null;
		}
		if (TDMController.myTeam == PunTeams.Team.red)
		{
			UISprite[] componentsInChildren = GetComponentsInChildren<UISprite>(true);
			foreach (UISprite sprite in componentsInChildren)
			{
				if (sprite.alpha != 0f && sprite.color == Color.white)
				{
					sprite.color = Color.green;
				}
			}
		}
		else
		{
			if (TDMController.myTeam != PunTeams.Team.blue)
			{
				yield break;
			}
			UISprite[] componentsInChildren2 = GetComponentsInChildren<UISprite>(true);
			foreach (UISprite sprite2 in componentsInChildren2)
			{
				if (sprite2.alpha != 0f && (sprite2.color == Color.white || sprite2.color == Color.green))
				{
					sprite2.color = Color.white;
				}
			}
		}
	}

	private IEnumerator UpdateWeapon()
	{
		yield return new WaitForEndOfFrame();
	}

	public override void OnPreShow(object userData)
	{
		if (joystickWalk != null)
		{
			joystickWalk.position = Vector2.zero;
		}
	}

	public override void OnHide()
	{
		if (joystickWalk != null)
		{
			joystickWalk.position = Vector2.zero;
		}
	}

	public void animDamage()
	{
		if (!GameController.instance.playerScript.isShock)
		{
			HOTween.Kill(textDamage);
			HOTween.To(textDamage, 0.15f, new TweenParms().Prop("alpha", 1f));
			HOTween.To(textDamage, 0.15f, new TweenParms().Delay(0.15f).Prop("alpha", 0f));
		}
	}

	public void animShock()
	{
		HOTween.Kill(textShock);
		MyDebug.Log("animShock");
		joystickWalk.position = Vector2.zero;
		ShockAlpha1();
	}

	private void ShockAlpha1()
	{
		HOTween.To(textShock, 0.15f, new TweenParms().Prop("alpha", 1f).OnComplete(ShockAlpha0));
	}

	private void ShockAlpha0()
	{
		HOTween.To(textShock, 0.15f, new TweenParms().Prop("alpha", 0.2f).OnComplete(ShockAlpha1));
	}

	public void stopAnimShock()
	{
		MyDebug.Log("stopAnimShock");
		HOTween.Kill(textShock);
		HOTween.To(textShock, 0.2f, new TweenParms().Prop("alpha", 0f));
	}

	public void HideTextureDamage()
	{
		textDamage.alpha = 0f;
		textShock.alpha = 0f;
	}
}
